<?php

namespace app\service;

use app\model\SysIntro;
class SysIntroService
{
    protected  $sysIntro;

    public function __construct()
    {
        $this->sysIntro = new SysIntro();
    }

    public function save($params=[])
    {
        $result = $this->sysIntro->where('mark',$params['mark'])->find()??new SysIntro();

        return  $result->allowField(['title','content','mark','cover','status','description'])->save($params);
    }

    public function index()
    {
        return $this->sysIntro->select();
    }

    public function getByMark($mark)
    {
        return $this->sysIntro->where('mark','IN',$mark)->select();
    }

    public function read($id)
    {
        return $this->sysIntro->find($id);
    }

    public function getByMarkOne($mark)
    {
        return $this->sysIntro->where('mark',$mark)->find();
    }
}
